<?php

namespace app\model;

use support\Model;

class AnnModel extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'ann';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    /**
     * 软删除字段
     *
     * @var string
     */
    protected $deletedAt = 'deleted_at';

    /**
     * 查询时排除已删除的记录
     */
    public function scopeNotDeleted($query)
    {
        return $query->whereNull('deleted_at');
    }

    /**
     * 软删除
     */
    public function softDelete()
    {
        $this->deleted_at = time();
        return $this->save();
    }
}